home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / ddragon.c < prev    next >
C/C++ Source or Header  |  2000-04-04  |  24KB  |  747 lines

  1. /*
  2. Double Dragon, Double Dragon (bootleg) & Double Dragon II
  3.  
  4. By Carlos A. Lozano & Rob Rosenbrock
  5. Help to do the original drivers from Chris Moore
  6. Sprite CPU support and additional code by Phil Stroffolino
  7. Sprite CPU emulation, vblank support, and partial sound code by Ernesto Corvi.
  8. Dipswitch to dd2 by Marco Cassili.
  9. High Score support by Roberto Fresca.
  10.  
  11. TODO:
  12. - Find the original MCU code so original Double Dragon ROMs can be supported
  13.  
  14. NOTES:
  15. The OKI M5205 chip 0 sampling rate is 8000hz (8khz).
  16. The OKI M5205 chip 1 sampling rate is 4000hz (4khz).
  17. Until the ADPCM interface is updated to be able to use
  18. multiple sampling rates, all samples currently play at 8khz.
  19. */
  20.  
  21. #include "driver.h"
  22. #include "vidhrdw/generic.h"
  23. #include "cpu/m6809/m6809.h"
  24. #include "cpu/z80/z80.h"
  25.  
  26. /* from vidhrdw */
  27. extern unsigned char *dd_videoram;
  28. extern int dd_scrollx_hi, dd_scrolly_hi;
  29. extern unsigned char *dd_scrollx_lo;
  30. extern unsigned char *dd_scrolly_lo;
  31. int dd_vh_start(void);
  32. void dd_vh_stop(void);
  33. void dd_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
  34. WRITE_HANDLER( dd_background_w );
  35. extern unsigned char *dd_spriteram;
  36. extern int dd2_video;
  37. /* end of extern code & data */
  38.  
  39. /* private globals */
  40. static int dd_sub_cpu_busy;
  41. static int sprite_irq, sound_irq, ym_irq;
  42. /* end of private globals */
  43.  
  44. static void dd_init_machine( void ) {
  45.     sprite_irq = M6809_INT_NMI;
  46.     sound_irq = M6809_INT_IRQ;
  47.     ym_irq = 1;//M6809_INT_FIRQ;
  48.     dd2_video = 0;
  49.     dd_sub_cpu_busy = 0x10;
  50. }
  51.  
  52. static void dd2_init_machine( void ) {
  53.     sprite_irq = Z80_NMI_INT;
  54.     sound_irq = Z80_NMI_INT;
  55.     ym_irq = 0;//-1000;
  56.     dd2_video = 1;
  57.     dd_sub_cpu_busy = 0x10;
  58. }
  59.  
  60. static WRITE_HANDLER( dd_bankswitch_w )
  61. {
  62.     unsigned char *RAM = memory_region(REGION_CPU1);
  63.  
  64.     dd_scrolly_hi = ( ( data & 0x02 ) << 7 );
  65.     dd_scrollx_hi = ( ( data & 0x01 ) << 8 );
  66.  
  67.     if ( ( data & 0x10 ) == 0x10 ) {
  68.         dd_sub_cpu_busy = 0x00;
  69.     } else if ( dd_sub_cpu_busy == 0x00 )
  70.             cpu_cause_interrupt( 1, sprite_irq );
  71.  
  72.     cpu_setbank( 1,&RAM[ 0x10000 + ( 0x4000 * ( ( data >> 5 ) & 7 ) ) ] );
  73. }
  74.  
  75. static WRITE_HANDLER( dd_forcedIRQ_w ) {
  76.     cpu_cause_interrupt( 0, M6809_INT_IRQ );
  77. }
  78.  
  79. static READ_HANDLER( port4_r ) {
  80.     int port = readinputport( 4 );
  81.  
  82.     return port | dd_sub_cpu_busy;
  83. }
  84.  
  85. static READ_HANDLER( dd_spriteram_r ){
  86.     return dd_spriteram[offset];
  87. }
  88.  
  89. static WRITE_HANDLER( dd_spriteram_w ) {
  90.  
  91.     if ( cpu_getactivecpu() == 1 && offset == 0 )
  92.         dd_sub_cpu_busy = 0x10;
  93.  
  94.     dd_spriteram[offset] = data;
  95. }
  96.  
  97. static WRITE_HANDLER( cpu_sound_command_w ) {
  98.     soundlatch_w( offset, data );
  99.     cpu_cause_interrupt( 2, sound_irq );
  100. }
  101.  
  102. static WRITE_HANDLER( dd_adpcm_w )
  103. {
  104.     static int start[2],end[2];
  105.     int chip = offset & 1;
  106.  
  107.  
  108.     offset >>= 1;
  109.  
  110.     switch (offset)
  111.     {
  112.         case 3:
  113.             break;
  114.  
  115.         case 2:
  116.             start[chip] = data & 0x7f;
  117.             break;
  118.  
  119.         case 1:
  120.             end[chip] = data & 0x7f;
  121.             break;
  122.  
  123.         case 0:
  124.             ADPCM_play( chip, 0x10000*chip + start[chip]*0x200, (end[chip]-start[chip])*0x400);
  125.             break;
  126.     }
  127. }
  128.  
  129. static READ_HANDLER( dd_adpcm_status_r )
  130. {
  131.     return ( ADPCM_playing( 0 ) + ( ADPCM_playing( 1 ) << 1 ) );
  132. }
  133.  
  134.  
  135.  
  136. static struct MemoryReadAddress readmem[] =
  137. {
  138.     { 0x0000, 0x1fff, MRA_RAM },
  139.     { 0x2000, 0x2fff, dd_spriteram_r },
  140.     { 0x3000, 0x37ff, MRA_RAM },
  141.     { 0x3800, 0x3800, input_port_0_r },
  142.     { 0x3801, 0x3801, input_port_1_r },
  143.     { 0x3802, 0x3802, port4_r },
  144.     { 0x3803, 0x3803, input_port_2_r },
  145.     { 0x3804, 0x3804, input_port_3_r },
  146.     { 0x3805, 0x3fff, MRA_RAM },
  147.     { 0x4000, 0x7fff, MRA_BANK1 },
  148.     { 0x8000, 0xffff, MRA_ROM },
  149.     { -1 }    /* end of table */
  150. };
  151.  
  152. static struct MemoryWriteAddress writemem[] =
  153. {
  154.     { 0x0000, 0x0fff, MWA_RAM },
  155.     { 0x1000, 0x11ff, paletteram_xxxxBBBBGGGGRRRR_split1_w, &paletteram },
  156.     { 0x1200, 0x13ff, paletteram_xxxxBBBBGGGGRRRR_split2_w, &paletteram_2 },
  157.     { 0x1400, 0x17ff, MWA_RAM },
  158.     { 0x1800, 0x1fff, MWA_RAM, &videoram },
  159.     { 0x2000, 0x2fff, dd_spriteram_w, &dd_spriteram },
  160.     { 0x3000, 0x37ff, dd_background_w, &dd_videoram },
  161.     { 0x3800, 0x3807, MWA_RAM },
  162.     { 0x3808, 0x3808, dd_bankswitch_w },
  163.     { 0x3809, 0x3809, MWA_RAM, &dd_scrollx_lo },
  164.     { 0x380a, 0x380a, MWA_RAM, &dd_scrolly_lo },
  165.     { 0x380b, 0x380b, MWA_RAM },
  166.     { 0x380c, 0x380d, MWA_RAM },
  167.     { 0x380e, 0x380e, cpu_sound_command_w },
  168.     { 0x380f, 0x380f, dd_forcedIRQ_w },
  169.     { 0x3810, 0x3fff, MWA_RAM },
  170.     { 0x4000, 0xffff, MWA_ROM },
  171.     { -1 }    /* end of table */
  172. };
  173.  
  174. static struct MemoryWriteAddress dd2_writemem[] =
  175. {
  176.     { 0x0000, 0x17ff, MWA_RAM },
  177.     { 0x1800, 0x1fff, MWA_RAM, &videoram },
  178.     { 0x2000, 0x2fff, dd_spriteram_w, &dd_spriteram },
  179.     { 0x3000, 0x37ff, dd_background_w, &dd_videoram },
  180.     { 0x3800, 0x3807, MWA_RAM },
  181.     { 0x3808, 0x3808, dd_bankswitch_w },
  182.     { 0x3809, 0x3809, MWA_RAM, &dd_scrollx_lo },
  183.     { 0x380a, 0x380a, MWA_RAM, &dd_scrolly_lo },
  184.     { 0x380b, 0x380b, MWA_RAM },
  185.     { 0x380c, 0x380d, MWA_RAM },
  186.     { 0x380e, 0x380e, cpu_sound_command_w },
  187.     { 0x380f, 0x380f, dd_forcedIRQ_w },
  188.     { 0x3810, 0x3bff, MWA_RAM },
  189.     { 0x3c00, 0x3dff, paletteram_xxxxBBBBGGGGRRRR_split1_w, &paletteram },
  190.     { 0x3e00, 0x3fff, paletteram_xxxxBBBBGGGGRRRR_split2_w, &paletteram_2 },
  191.     { 0x4000, 0xffff, MWA_ROM },
  192.     { -1 }    /* end of table */
  193. };
  194.  
  195. static struct MemoryReadAddress sub_readmem[] =
  196. {
  197.     { 0x0000, 0x0fff, MRA_RAM },
  198.     { 0x8000, 0x8fff, dd_spriteram_r },
  199.     { 0xc000, 0xffff, MRA_ROM },
  200.     { -1 }    /* end of table */
  201. };
  202.  
  203. static struct MemoryWriteAddress sub_writemem[] =
  204. {
  205.     { 0x0000, 0x0fff, MWA_RAM },
  206.     { 0x8000, 0x8fff, dd_spriteram_w },
  207.     { 0xc000, 0xffff, MWA_ROM },
  208.     { -1 }    /* end of table */
  209. };
  210.  
  211. static struct MemoryReadAddress sound_readmem[] =
  212. {
  213.     { 0x0000, 0x0fff, MRA_RAM },
  214.     { 0x1000, 0x1000, soundlatch_r },
  215.     { 0x1800, 0x1800, dd_adpcm_status_r },
  216.     { 0x2800, 0x2801, YM2151_status_port_0_r },
  217.     { 0x8000, 0xffff, MRA_ROM },
  218.     { -1 }    /* end of table */
  219. };
  220.  
  221. static struct MemoryWriteAddress sound_writemem[] =
  222. {
  223.     { 0x0000, 0x0fff, MWA_RAM },
  224.     { 0x2800, 0x2800, YM2151_register_port_0_w },
  225.     { 0x2801, 0x2801, YM2151_data_port_0_w },
  226.     { 0x3800, 0x3807, dd_adpcm_w },
  227.     { 0x8000, 0xffff, MWA_ROM },
  228.     { -1 }    /* end of table */
  229. };
  230.  
  231. static struct MemoryReadAddress dd2_sub_readmem[] =
  232. {
  233.     { 0x0000, 0xbfff, MRA_ROM },
  234.     { 0xc000, 0xcfff, dd_spriteram_r },
  235.     { 0xd000, 0xffff, MRA_RAM },
  236.     { -1 }    /* end of table */
  237. };
  238.  
  239. static struct MemoryWriteAddress dd2_sub_writemem[] =
  240. {
  241.     { 0x0000, 0xbfff, MWA_ROM },
  242.     { 0xc000, 0xcfff, dd_spriteram_w },
  243.     { 0xd000, 0xffff, MWA_RAM },
  244.     { -1 }    /* end of table */
  245. };
  246.  
  247. static struct MemoryReadAddress dd2_sound_readmem[] =
  248. {
  249.     { 0x0000, 0x7fff, MRA_ROM },
  250.     { 0x8000, 0x87ff, MRA_RAM },
  251.     { 0x8801, 0x8801, YM2151_status_port_0_r },
  252.     { 0x9800, 0x9800, OKIM6295_status_0_r },
  253.     { 0xA000, 0xA000, soundlatch_r },
  254.     { -1 }    /* end of table */
  255. };
  256.  
  257. static struct MemoryWriteAddress dd2_sound_writemem[] =
  258. {
  259.     { 0x0000, 0x7fff, MWA_ROM },
  260.     { 0x8000, 0x87ff, MWA_RAM },
  261.     { 0x8800, 0x8800, YM2151_register_port_0_w },
  262.     { 0x8801, 0x8801, YM2151_data_port_0_w },
  263.     { 0x9800, 0x9800, OKIM6295_data_0_w },
  264.     { -1 }    /* end of table */
  265. };
  266.  
  267. /* bit 0x10 is sprite CPU busy signal */
  268. #define COMMON_PORT4    PORT_START \
  269.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN3 ) \
  270.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON3 ) \
  271.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER2 ) \
  272.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_VBLANK ) \
  273.     PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNKNOWN ) \
  274.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN ) \
  275.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN ) \
  276.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
  277.  
  278. #define COMMON_INPUT_PORTS PORT_START \
  279.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY ) \
  280.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY ) \
  281.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY ) \
  282.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY ) \
  283.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) \
  284.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) \
  285.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START1 ) \
  286.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2 ) \
  287.     PORT_START \
  288.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER2 ) \
  289.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER2 ) \
  290.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_PLAYER2 ) \
  291.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER2 ) \
  292.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 ) \
  293.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 ) \
  294.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 ) \
  295.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN2 ) \
  296.     PORT_START \
  297.     PORT_DIPNAME( 0x07, 0x07, DEF_STR( Coin_A ) ) \
  298.     PORT_DIPSETTING(    0x00, DEF_STR( 4C_1C ) ) \
  299.     PORT_DIPSETTING(    0x01, DEF_STR( 3C_1C ) ) \
  300.     PORT_DIPSETTING(    0x02, DEF_STR( 2C_1C ) ) \
  301.     PORT_DIPSETTING(    0x07, DEF_STR( 1C_1C ) ) \
  302.     PORT_DIPSETTING(    0x06, DEF_STR( 1C_2C ) ) \
  303.     PORT_DIPSETTING(    0x05, DEF_STR( 1C_3C ) ) \
  304.     PORT_DIPSETTING(    0x04, DEF_STR( 1C_4C ) ) \
  305.     PORT_DIPSETTING(    0x03, DEF_STR( 1C_5C ) ) \
  306.     PORT_DIPNAME( 0x38, 0x38, DEF_STR( Coin_B ) ) \
  307.     PORT_DIPSETTING(    0x00, DEF_STR( 4C_1C ) ) \
  308.     PORT_DIPSETTING(    0x08, DEF_STR( 3C_1C ) ) \
  309.     PORT_DIPSETTING(    0x10, DEF_STR( 2C_1C ) ) \
  310.     PORT_DIPSETTING(    0x38, DEF_STR( 1C_1C ) ) \
  311.     PORT_DIPSETTING(    0x30, DEF_STR( 1C_2C ) ) \
  312.     PORT_DIPSETTING(    0x28, DEF_STR( 1C_3C ) ) \
  313.     PORT_DIPSETTING(    0x20, DEF_STR( 1C_4C ) ) \
  314.     PORT_DIPSETTING(    0x18, DEF_STR( 1C_5C ) ) \
  315.     PORT_DIPNAME( 0x40, 0x40, "Screen Orientation?" ) \
  316.     PORT_DIPSETTING(    0x40, DEF_STR( Off )) \
  317.     PORT_DIPSETTING(    0x00, DEF_STR( On ) ) \
  318.     PORT_DIPNAME( 0x80, 0x80, DEF_STR( Flip_Screen ) ) \
  319.     PORT_DIPSETTING(    0x80, DEF_STR( Off )) \
  320.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  321.  
  322. INPUT_PORTS_START( dd1 )
  323.     COMMON_INPUT_PORTS
  324.  
  325.     PORT_START      /* DSW1 */
  326.     PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) )
  327.     PORT_DIPSETTING(    0x02, "Easy")
  328.     PORT_DIPSETTING(    0x03, "Normal")
  329.     PORT_DIPSETTING(    0x01, "Hard")
  330.     PORT_DIPSETTING(    0x00, "Very Hard")
  331.     PORT_DIPNAME( 0x04, 0x04, DEF_STR( Demo_Sounds ) )
  332.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  333.     PORT_DIPSETTING(    0x04, DEF_STR( On ))
  334.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNUSED )
  335.     PORT_DIPNAME( 0x30, 0x30, DEF_STR( Bonus_Life ) )
  336.     PORT_DIPSETTING(    0x10, "20k")
  337.     PORT_DIPSETTING(    0x00, "40k" )
  338.     PORT_DIPSETTING(    0x30, "30k and every 60k")
  339.     PORT_DIPSETTING(    0x20, "40k and every 80k" )
  340.     PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Lives ) )
  341.     PORT_DIPSETTING(    0xc0, "2")
  342.     PORT_DIPSETTING(    0x80, "3" )
  343.     PORT_DIPSETTING(    0x40, "4")
  344.     PORT_BITX( 0,       0x00, IPT_DIPSWITCH_SETTING | IPF_CHEAT, "Infinite", IP_KEY_NONE, IP_JOY_NONE )
  345.  
  346.     COMMON_PORT4
  347. INPUT_PORTS_END
  348.  
  349. INPUT_PORTS_START( dd2 )
  350.     COMMON_INPUT_PORTS
  351.  
  352.   PORT_START      /* DSW1 */
  353.     PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) )
  354.     PORT_DIPSETTING(    0x02, "Easy")
  355.     PORT_DIPSETTING(    0x03, "Normal")
  356.     PORT_DIPSETTING(    0x01, "Medium")
  357.     PORT_DIPSETTING(    0x00, "Hard")
  358.     PORT_DIPNAME( 0x04, 0x04, DEF_STR( Demo_Sounds ) )
  359.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  360.     PORT_DIPSETTING(    0x04, DEF_STR( On ))
  361.     PORT_DIPNAME( 0x08, 0x08, "Hurricane Kick" )
  362.     PORT_DIPSETTING(    0x00, "Easy" )
  363.     PORT_DIPSETTING(    0x08, "Normal" )
  364.     PORT_DIPNAME( 0x30, 0x30, "Timer" )
  365.     PORT_DIPSETTING(    0x00, "60" )
  366.     PORT_DIPSETTING(    0x10, "65" )
  367.     PORT_DIPSETTING(    0x30, "70" )
  368.     PORT_DIPSETTING(    0x20, "80" )
  369.     PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Lives ) )
  370.     PORT_DIPSETTING(    0xc0, "1" )
  371.     PORT_DIPSETTING(    0x80, "2" )
  372.     PORT_DIPSETTING(    0x40, "3" )
  373.     PORT_DIPSETTING(    0x00, "4" )
  374.  
  375.     COMMON_PORT4
  376. INPUT_PORTS_END
  377.  
  378. #undef COMMON_INPUT_PORTS
  379. #undef COMMON_PORT4
  380.  
  381. #define CHAR_LAYOUT( name, num ) \
  382.     static struct GfxLayout name = \
  383.     { \
  384.         8,8, /* 8*8 chars */ \
  385.         num, /* 'num' characters */ \
  386.         4, /* 4 bits per pixel */ \
  387.         { 0, 2, 4, 6 }, /* plane offset */ \
  388.         { 1, 0, 65, 64, 129, 128, 193, 192 }, \
  389.         { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },    \
  390.         32*8 /* every char takes 32 consecutive bytes */ \
  391.     };
  392.  
  393. #define TILE_LAYOUT( name, num, planeoffset ) \
  394.     static struct GfxLayout name = \
  395.     { \
  396.         16,16, /* 16x16 chars */ \
  397.         num, /* 'num' characters */ \
  398.         4, /* 4 bits per pixel */ \
  399.         { planeoffset*8+0, planeoffset*8+4, 0,4 }, /* plane offset */ \
  400.         { 3, 2, 1, 0, 16*8+3, 16*8+2, 16*8+1, 16*8+0, \
  401.               32*8+3,32*8+2 ,32*8+1 ,32*8+0 ,48*8+3 ,48*8+2 ,48*8+1 ,48*8+0 }, \
  402.         { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, \
  403.               8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8 }, \
  404.         64*8 /* every char takes 64 consecutive bytes */ \
  405.     };
  406.  
  407. CHAR_LAYOUT( char_layout, 1024 ) /* foreground chars */
  408. TILE_LAYOUT( tile_layout, 2048, 0x20000 ) /* background tiles */
  409. TILE_LAYOUT( sprite_layout, 2048*2, 0x40000 ) /* sprites */
  410.  
  411. static struct GfxDecodeInfo gfxdecodeinfo[] =
  412. {
  413.     { REGION_GFX1, 0, &char_layout,        0, 8 },    /* 8x8 text */
  414.     { REGION_GFX2, 0, &sprite_layout, 128, 8 },    /* 16x16 sprites */
  415.     { REGION_GFX3, 0, &tile_layout,      256, 8 }, /* 16x16 background tiles */
  416.     { -1 }
  417. };
  418.  
  419. CHAR_LAYOUT( dd2_char_layout, 2048 ) /* foreground chars */
  420. TILE_LAYOUT( dd2_sprite_layout, 2048*3, 0x60000 ) /* sprites */
  421.  
  422. /* background tiles encoding for dd2 is the same as dd1 */
  423.  
  424. static struct GfxDecodeInfo dd2_gfxdecodeinfo[] =
  425. {
  426.     { REGION_GFX1, 0, &dd2_char_layout,        0, 8 },    /* 8x8 chars */
  427.     { REGION_GFX2, 0, &dd2_sprite_layout, 128, 8 },    /* 16x16 sprites */
  428.     { REGION_GFX3, 0, &tile_layout,       256, 8 },    /* 16x16 background tiles */
  429.     { -1 } // end of array
  430. };
  431.  
  432. static void dd_irq_handler(int irq) {
  433.     cpu_set_irq_line( 2, ym_irq , irq ? ASSERT_LINE : CLEAR_LINE );
  434. }
  435.  
  436. static struct YM2151interface ym2151_interface =
  437. {
  438.     1,            /* 1 chip */
  439.     3579545,    /* ??? */
  440.     { YM3012_VOL(60,MIXER_PAN_LEFT,60,MIXER_PAN_RIGHT) },
  441.     { dd_irq_handler }
  442. };
  443.  
  444. static struct ADPCMinterface adpcm_interface =
  445. {
  446.     2,            /* 2 channels */
  447.     8000,       /* 8000Hz playback */
  448.     REGION_SOUND1,    /* memory region 4 */
  449.     0,            /* init function */
  450.     { 50, 50 }
  451. };
  452.  
  453. static struct OKIM6295interface okim6295_interface =
  454. {
  455.     1,              /* 1 chip */
  456.     { 8000 },           /* frequency (Hz) */
  457.     { REGION_SOUND1 },  /* memory region */
  458.     { 15 }
  459. };
  460.  
  461. static int dd_interrupt(void)
  462. {
  463.     cpu_set_irq_line(0, 1, HOLD_LINE); /* hold the FIRQ line */
  464.     cpu_set_nmi_line(0, PULSE_LINE); /* pulse the NMI line */
  465.     return M6809_INT_NONE;
  466. }
  467.  
  468.  
  469.  
  470. static struct MachineDriver machine_driver_ddragon =
  471. {
  472.     /* basic machine hardware */
  473.     {
  474.         {
  475.              CPU_HD6309,
  476.             3579545,    /* 3.579545 Mhz */
  477.             readmem,writemem,0,0,
  478.             dd_interrupt,1
  479.         },
  480.         {
  481.              CPU_HD63701, /* we're missing the code for this one */
  482.             2000000, /* 2 Mhz ???*/
  483.             sub_readmem,sub_writemem,0,0,
  484.             ignore_interrupt,0
  485.         },
  486.         {
  487.              CPU_HD6309 | CPU_AUDIO_CPU,    /* ? */
  488.             3579545,    /* 3.579545 Mhz */
  489.             sound_readmem,sound_writemem,0,0,
  490.             ignore_interrupt,0 /* irq on command */
  491.         }
  492.     },
  493.     60, DEFAULT_REAL_60HZ_VBLANK_DURATION, /* frames per second, vblank duration */
  494.     100, /* heavy interleaving to sync up sprite<->main cpu's */
  495.     dd_init_machine,
  496.  
  497.     /* video hardware */
  498.     32*8, 32*8,{ 1*8, 31*8-1, 2*8, 30*8-1 },
  499.     gfxdecodeinfo,
  500.     384, 384,
  501.     0,
  502.     VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE,
  503.     0,
  504.     dd_vh_start,
  505.     dd_vh_stop,
  506.     dd_vh_screenrefresh,
  507.  
  508.     /* sound hardware */
  509.     SOUND_SUPPORTS_STEREO,0,0,0,
  510.     {
  511.         {
  512.             SOUND_YM2151,
  513.             &ym2151_interface
  514.         },
  515.         {
  516.             SOUND_ADPCM,
  517.             &adpcm_interface
  518.         }
  519.     }
  520. };
  521.  
  522. static struct MachineDriver machine_driver_ddragonb =
  523. {
  524.     /* basic machine hardware */
  525.     {
  526.         {
  527.              CPU_HD6309,
  528.             3579545,    /* 3.579545 Mhz */
  529.             readmem,writemem,0,0,
  530.             dd_interrupt,1
  531.         },
  532.         {
  533.              CPU_HD6309,    /* ? */
  534.             12000000 / 3, /* 4 Mhz */
  535.             sub_readmem,sub_writemem,0,0,
  536.             ignore_interrupt,0
  537.         },
  538.         {
  539.              CPU_HD6309 | CPU_AUDIO_CPU,    /* ? */
  540.             3579545,    /* 3.579545 Mhz */
  541.             sound_readmem,sound_writemem,0,0,
  542.             ignore_interrupt,0 /* irq on command */
  543.         }
  544.     },
  545.     60, DEFAULT_REAL_60HZ_VBLANK_DURATION, /* frames per second, vblank duration */
  546.     100, /* heavy interleaving to sync up sprite<->main cpu's */
  547.     dd_init_machine,
  548.  
  549.     /* video hardware */
  550.     32*8, 32*8,{ 1*8, 31*8-1, 2*8, 30*8-1 },
  551.     gfxdecodeinfo,
  552.     384, 384,
  553.     0,
  554.     VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE,
  555.     0,
  556.     dd_vh_start,
  557.     dd_vh_stop,
  558.     dd_vh_screenrefresh,
  559.  
  560.     /* sound hardware */
  561.     SOUND_SUPPORTS_STEREO,0,0,0,
  562.     {
  563.         {
  564.             SOUND_YM2151,
  565.             &ym2151_interface
  566.         },
  567.         {
  568.             SOUND_ADPCM,
  569.             &adpcm_interface
  570.         }
  571.     }
  572. };
  573.  
  574. static struct MachineDriver machine_driver_ddragon2 =
  575. {
  576.     /* basic machine hardware */
  577.     {
  578.         {
  579.              CPU_HD6309,
  580.             3579545,    /* 3.579545 Mhz */
  581.             readmem,dd2_writemem,0,0,
  582.             dd_interrupt,1
  583.         },
  584.         {
  585.             CPU_Z80,
  586.             12000000 / 3, /* 4 Mhz */
  587.             dd2_sub_readmem,dd2_sub_writemem,0,0,
  588.             ignore_interrupt,0
  589.         },
  590.         {
  591.             CPU_Z80 | CPU_AUDIO_CPU,
  592.             3579545,    /* 3.579545 Mhz */
  593.             dd2_sound_readmem,dd2_sound_writemem,0,0,
  594.             ignore_interrupt,0
  595.         }
  596.     },
  597.     60, DEFAULT_REAL_60HZ_VBLANK_DURATION, /* frames per second, vblank duration */
  598.     100, /* heavy interleaving to sync up sprite<->main cpu's */
  599.     dd2_init_machine,
  600.  
  601.     /* video hardware */
  602.     32*8, 32*8,{ 1*8, 31*8-1, 2*8, 30*8-1 },
  603.     dd2_gfxdecodeinfo,
  604.     384, 384,
  605.     0,
  606.  
  607.     VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE,
  608.     0,
  609.     dd_vh_start,
  610.     dd_vh_stop,
  611.     dd_vh_screenrefresh,
  612.  
  613.     /* sound hardware */
  614.     SOUND_SUPPORTS_STEREO,0,0,0,
  615.     {
  616.         {
  617.             SOUND_YM2151,
  618.             &ym2151_interface
  619.         },
  620.         {
  621.             SOUND_OKIM6295,
  622.             &okim6295_interface
  623.         }
  624.     }
  625. };
  626.  
  627. /***************************************************************************
  628.  
  629.   Game driver(s)
  630.  
  631. ***************************************************************************/
  632.  
  633.  
  634. ROM_START( ddragon )
  635.     ROM_REGION( 0x28000, REGION_CPU1 )    /* 64k for code + bankswitched memory */
  636.     ROM_LOAD( "a_m2_d02.bin", 0x08000, 0x08000, 0x668dfa19 )
  637.     ROM_LOAD( "a_k2_d03.bin", 0x10000, 0x08000, 0x5779705e ) /* banked at 0x4000-0x8000 */
  638.     ROM_LOAD( "a_h2_d04.bin", 0x18000, 0x08000, 0x3bdea613 ) /* banked at 0x4000-0x8000 */
  639.     ROM_LOAD( "a_g2_d05.bin", 0x20000, 0x08000, 0x728f87b9 ) /* banked at 0x4000-0x8000 */
  640.  
  641.     ROM_REGION( 0x10000, REGION_CPU2 ) /* sprite cpu */
  642.     /* missing mcu code */
  643.     ROM_LOAD( "63701.bin", 0xc000, 0x4000, 0x00000000 )
  644.  
  645.     ROM_REGION( 0x10000, REGION_CPU3 ) /* audio cpu */
  646.     ROM_LOAD( "a_s2_d01.bin", 0x08000, 0x08000, 0x9efa95bb )
  647.  
  648.     ROM_REGION( 0x08000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  649.     ROM_LOAD( "a_a2_d06.bin", 0x00000, 0x08000, 0x7a8b8db4 ) /* 0,1,2,3 */ /* text */
  650.  
  651.     ROM_REGION( 0x80000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  652.     ROM_LOAD( "b_r7_d11.bin", 0x00000, 0x10000, 0x574face3 ) /* 0,1 */ /* sprites */
  653.     ROM_LOAD( "b_p7_d12.bin", 0x10000, 0x10000, 0x40507a76 ) /* 0,1 */ /* sprites */
  654.     ROM_LOAD( "b_m7_d13.bin", 0x20000, 0x10000, 0xbb0bc76f ) /* 0,1 */ /* sprites */
  655.     ROM_LOAD( "b_l7_d14.bin", 0x30000, 0x10000, 0xcb4f231b ) /* 0,1 */ /* sprites */
  656.     ROM_LOAD( "b_j7_d15.bin", 0x40000, 0x10000, 0xa0a0c261 ) /* 2,3 */ /* sprites */
  657.     ROM_LOAD( "b_h7_d16.bin", 0x50000, 0x10000, 0x6ba152f6 ) /* 2,3 */ /* sprites */
  658.     ROM_LOAD( "b_f7_d17.bin", 0x60000, 0x10000, 0x3220a0b6 ) /* 2,3 */ /* sprites */
  659.     ROM_LOAD( "b_d7_d18.bin", 0x70000, 0x10000, 0x65c7517d ) /* 2,3 */ /* sprites */
  660.  
  661.     ROM_REGION( 0x40000, REGION_GFX3 | REGIONFLAG_DISPOSE )
  662.     ROM_LOAD( "b_c5_d09.bin", 0x00000, 0x10000, 0x7c435887 ) /* 0,1 */ /* tiles */
  663.     ROM_LOAD( "b_a5_d10.bin", 0x10000, 0x10000, 0xc6640aed ) /* 0,1 */ /* tiles */
  664.     ROM_LOAD( "b_c7_d19.bin", 0x20000, 0x10000, 0x5effb0a0 ) /* 2,3 */ /* tiles */
  665.     ROM_LOAD( "b_a7_d20.bin", 0x30000, 0x10000, 0x5fb42e7c ) /* 2,3 */ /* tiles */
  666.  
  667.     ROM_REGION( 0x20000, REGION_SOUND1 ) /* adpcm samples */
  668.     ROM_LOAD( "a_s6_d07.bin", 0x00000, 0x10000, 0x34755de3 )
  669.     ROM_LOAD( "a_r6_d08.bin", 0x10000, 0x10000, 0x904de6f8 )
  670. ROM_END
  671.  
  672. ROM_START( ddragonb )
  673.     ROM_REGION( 0x28000, REGION_CPU1 )    /* 64k for code + bankswitched memory */
  674.     ROM_LOAD( "ic26",         0x08000, 0x08000, 0xae714964 )
  675.     ROM_LOAD( "a_k2_d03.bin", 0x10000, 0x08000, 0x5779705e ) /* banked at 0x4000-0x8000 */
  676.     ROM_LOAD( "ic24",         0x18000, 0x08000, 0xdbf24897 ) /* banked at 0x4000-0x8000 */
  677.     ROM_LOAD( "ic23",         0x20000, 0x08000, 0x6c9f46fa ) /* banked at 0x4000-0x8000 */
  678.  
  679.     ROM_REGION( 0x10000, REGION_CPU2 ) /* sprite cpu */
  680.     ROM_LOAD( "ic38",         0x0c000, 0x04000, 0x6a6a0325 )
  681.  
  682.     ROM_REGION( 0x10000, REGION_CPU3 ) /* audio cpu */
  683.     ROM_LOAD( "a_s2_d01.bin", 0x08000, 0x08000, 0x9efa95bb )
  684.  
  685.     ROM_REGION( 0x08000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  686.     ROM_LOAD( "a_a2_d06.bin", 0x00000, 0x08000, 0x7a8b8db4 ) /* 0,1,2,3 */ /* text */
  687.  
  688.     ROM_REGION( 0x80000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  689.     ROM_LOAD( "b_r7_d11.bin", 0x00000, 0x10000, 0x574face3 ) /* 0,1 */ /* sprites */
  690.     ROM_LOAD( "b_p7_d12.bin", 0x10000, 0x10000, 0x40507a76 ) /* 0,1 */ /* sprites */
  691.     ROM_LOAD( "b_m7_d13.bin", 0x20000, 0x10000, 0xbb0bc76f ) /* 0,1 */ /* sprites */
  692.     ROM_LOAD( "b_l7_d14.bin", 0x30000, 0x10000, 0xcb4f231b ) /* 0,1 */ /* sprites */
  693.     ROM_LOAD( "b_j7_d15.bin", 0x40000, 0x10000, 0xa0a0c261 ) /* 2,3 */ /* sprites */
  694.     ROM_LOAD( "b_h7_d16.bin", 0x50000, 0x10000, 0x6ba152f6 ) /* 2,3 */ /* sprites */
  695.     ROM_LOAD( "b_f7_d17.bin", 0x60000, 0x10000, 0x3220a0b6 ) /* 2,3 */ /* sprites */
  696.     ROM_LOAD( "b_d7_d18.bin", 0x70000, 0x10000, 0x65c7517d ) /* 2,3 */ /* sprites */
  697.  
  698.     ROM_REGION( 0x40000, REGION_GFX3 | REGIONFLAG_DISPOSE )
  699.     ROM_LOAD( "b_c5_d09.bin", 0x00000, 0x10000, 0x7c435887 ) /* 0,1 */ /* tiles */
  700.     ROM_LOAD( "b_a5_d10.bin", 0x10000, 0x10000, 0xc6640aed ) /* 0,1 */ /* tiles */
  701.     ROM_LOAD( "b_c7_d19.bin", 0x20000, 0x10000, 0x5effb0a0 ) /* 2,3 */ /* tiles */
  702.     ROM_LOAD( "b_a7_d20.bin", 0x30000, 0x10000, 0x5fb42e7c ) /* 2,3 */ /* tiles */
  703.  
  704.     ROM_REGION( 0x20000, REGION_SOUND1 ) /* adpcm samples */
  705.     ROM_LOAD( "a_s6_d07.bin", 0x00000, 0x10000, 0x34755de3 )
  706.     ROM_LOAD( "a_r6_d08.bin", 0x10000, 0x10000, 0x904de6f8 )
  707. ROM_END
  708.  
  709. ROM_START( ddragon2 )
  710.     ROM_REGION( 0x28000, REGION_CPU1 )    /* region#0: 64k for code */
  711.     ROM_LOAD( "26a9-04.bin",  0x08000, 0x8000, 0xf2cfc649 )
  712.     ROM_LOAD( "26aa-03.bin",  0x10000, 0x8000, 0x44dd5d4b )
  713.     ROM_LOAD( "26ab-0.bin",   0x18000, 0x8000, 0x49ddddcd )
  714.     ROM_LOAD( "26ac-02.bin",  0x20000, 0x8000, 0x097eaf26 )
  715.  
  716.     ROM_REGION( 0x10000, REGION_CPU2 ) /* region#2: sprite CPU 64kb (Upper 16kb = 0) */
  717.     ROM_LOAD( "26ae-0.bin",   0x00000, 0x10000, 0xea437867 )
  718.  
  719.     ROM_REGION( 0x10000, REGION_CPU3 ) /* region#3: music CPU, 64kb */
  720.     ROM_LOAD( "26ad-0.bin",   0x00000, 0x8000, 0x75e36cd6 )
  721.  
  722.     ROM_REGION( 0x10000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  723.     ROM_LOAD( "26a8-0.bin",   0x00000, 0x10000, 0x3ad1049c ) /* 0,1,2,3 */ /* text */
  724.  
  725.     ROM_REGION( 0xc0000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  726.     ROM_LOAD( "26j0-0.bin",   0x00000, 0x20000, 0xdb309c84 ) /* 0,1 */ /* sprites */
  727.     ROM_LOAD( "26j1-0.bin",   0x20000, 0x20000, 0xc3081e0c ) /* 0,1 */ /* sprites */
  728.     ROM_LOAD( "26af-0.bin",   0x40000, 0x20000, 0x3a615aad ) /* 0,1 */ /* sprites */
  729.     ROM_LOAD( "26j2-0.bin",   0x60000, 0x20000, 0x589564ae ) /* 2,3 */ /* sprites */
  730.     ROM_LOAD( "26j3-0.bin",   0x80000, 0x20000, 0xdaf040d6 ) /* 2,3 */ /* sprites */
  731.     ROM_LOAD( "26a10-0.bin",  0xa0000, 0x20000, 0x6d16d889 ) /* 2,3 */ /* sprites */
  732.  
  733.     ROM_REGION( 0x40000, REGION_GFX3 | REGIONFLAG_DISPOSE )
  734.     ROM_LOAD( "26j4-0.bin",   0x00000, 0x20000, 0xa8c93e76 ) /* 0,1 */ /* tiles */
  735.     ROM_LOAD( "26j5-0.bin",   0x20000, 0x20000, 0xee555237 ) /* 2,3 */ /* tiles */
  736.  
  737.     ROM_REGION( 0x40000, REGION_SOUND1 ) /* region#4: adpcm */
  738.     ROM_LOAD( "26j6-0.bin",   0x00000, 0x20000, 0xa84b2a29 )
  739.     ROM_LOAD( "26j7-0.bin",   0x20000, 0x20000, 0xbc6a48d5 )
  740. ROM_END
  741.  
  742.  
  743.  
  744. GAMEX(1987, ddragon,  0,       ddragon,  dd1, 0, ROT0, "bootleg?", "Double Dragon", GAME_NOT_WORKING )
  745. GAME( 1987, ddragonb, ddragon, ddragonb, dd1, 0, ROT0, "bootleg", "Double Dragon (bootleg)" )
  746. GAME( 1988, ddragon2, 0,       ddragon2, dd2, 0, ROT0, "Technos", "Double Dragon II - The Revenge" )
  747.